using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace  QFramework
{
    public class ItemKit
    {
        public static UISlot CurrentSlotPointerOn = null;
        
        public static Dictionary<string, IItem> ItemByKey = new Dictionary<string, IItem>();

        public static Dictionary<string, SlotGroup> mSlotGroupByKey = new Dictionary<string, SlotGroup>();

        public static SlotGroup CreateSlotGroup(string key)
        {
            var slotGroup = new SlotGroup()
            {
                Key = key
            };
            mSlotGroupByKey.Add(key, slotGroup);
            return slotGroup;
        }

        public static SlotGroup GetSlotGroupByKey(string key)
        {
            return mSlotGroupByKey[key];
        }
        
        /// <summary>
        /// 添加进字典
        /// </summary>
        public static void AddItemConfig(IItem itemConfig)
        {
            ItemByKey.Add(itemConfig.GetKey, itemConfig);
        }

        
        public static void LoadItemDatabase(string databaseName)
        {
            var database = Resources.Load<ItemDatabase>(databaseName);
            foreach (var databaseItem in database.Items)
            {
                AddItemConfig(databaseItem);
            }
        }
    }
}

